package com.axxc.cloud.controller;

import javax.servlet.http.HttpServletRequest;

import org.apache.ibatis.session.RowBounds;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.axxc.cloud.model.ScBaseConcernRecommendRecord;
import com.axxc.cloud.model.query.PageQueryVo;
import com.axxc.cloud.service.api.IScBaseConcernRecommendRecordService;

@RequestMapping("boot-mybatis")
@RestController
public class ScBaseConcernRecommendRecordController extends BaseController {

	@Autowired
	private IScBaseConcernRecommendRecordService recommendRecordService;

	@PostMapping("concernRecommendRecord/list")
	public Object index() {
		return this.recommendRecordService.list();
	}

	@PostMapping("concernRecommendRecord/selectByExample")
	public Object selectByExample(@RequestBody PageQueryVo pageVo, HttpServletRequest request) {
		System.out.println(request.getRemoteAddr());// 来访Ip
		System.out.println(request.getLocalAddr());// 本机Ip
		System.out.println(request.getRequestURL());// 请求的绝对路径
		System.out.println(request.getMethod());// Http 方法类型
		// System.out.println(request.getPathInfo());
		System.out.println(request.getProtocol());// HTTP 协议版本
		// System.out.println(request.getParameterMap().toString());// 参数
		// System.out.println(request.getRequestedSessionId());
		System.out.println(request.getUserPrincipal());
		return this.recommendRecordService.listPageByExample(null, pageVo.getPageNum(), pageVo.getPageSize()).getList();
	}

	@PostMapping("concernRecommendRecord/selectByExampleAndRowBounds.json")
	public Object selectByExampleAndRowBounds(@Validated @RequestBody PageQueryVo pageVo) {
		RowBounds a = new RowBounds(pageVo.getPageNum(), pageVo.getPageSize());

		return this.recommendRecordService.selectByExampleAndRowBounds(null, a);
	}

	@PostMapping("test")
	public Object test(@RequestBody PageQueryVo pageVo) {
		RowBounds a = new RowBounds(pageVo.getPageNum(), pageVo.getPageSize());
		return this.recommendRecordService.selectByExampleAndRowBounds(null, a);
	}

	@PostMapping("testGet")
	public Object testGet(PageQueryVo pageVo) {
		RowBounds a = new RowBounds(pageVo.getPageNum(), pageVo.getPageSize());
		return this.recommendRecordService.selectByExampleAndRowBounds(null, a);
	}

	@PostMapping("concernRecommendRecord/testLog")
	public Object index(@RequestBody  ScBaseConcernRecommendRecord record) {
		return this.recommendRecordService.updateByPrimaryKeySelective(record);
	}
}
